require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsHardStoryHandler = {};
local this = RedDotsHardStoryHandler;

function RedDotsHardStoryHandler.init()
    CloseEvent(Config.EventType.HardStoryInfo, this.update);
    CloseEvent(Config.EventType.HardStoryOpen, this.update);
    ListenEvent(Config.EventType.HardStoryInfo, this.update);
    ListenEvent(Config.EventType.HardStoryOpen, this.update);
    return this;
end

--参数1：指定活动Id，nil代表检查活动中心
---活动红点
function RedDotsHardStoryHandler.getFlag(...)
    local flag = Config.RedDotsFlagState.None;
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.StoryModel) then
        if Util.GetPlayerPrefs("HardStoryRedDots") == nil then
            flag = Config.RedDotsFlagState.Needful;
        end
        if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.StoryModelReward) then
            if logicMgr.StoryHardManager.getPower()>=logicMgr.StoryHardManager.getAllPower() then
                flag = Config.RedDotsFlagState.Needful;
            end
        end
    end
    return flag;
end

function RedDotsHardStoryHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.HardStory);
end